﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Shoozla.DataModel;
using Shoozla;
using System.Windows;



namespace Shoozla.ViewModel
{
    public class OptionsViewModel : ViewModelBase
    {

        public OptionsViewModel(Window view, Window owner ): base(view,owner)
        {
            SelectedCoverPlugIn = AppModel.CoverSearcher;
        }

        public List<CoverSearcher> AddIns { get { return AppModel.AvailableCoverSearchers; } }
        public CoverSearcher SelectedCoverPlugIn { get; set; }

        #region Commands

        private RelayCommand _CmdSave;
        public RelayCommand CmdSave
        {
            get
            {
                if (_CmdSave == null)
                {
                    _CmdSave = new RelayCommand(param => DoCmdSave(), param => true);
                }
                return _CmdSave;
            }
        }

        private RelayCommand _CmdCancel;
        public RelayCommand CmdCancel
        {
            get
            {
                if (_CmdCancel == null)
                {
                    _CmdCancel = new RelayCommand(param => DoCmdCancel(), (c) => true);
                }
                return _CmdCancel;
            }
        }

        #endregion

        #region DoCommands

        private void DoCmdSave()
        {
            AppModel.CoverSearcher = SelectedCoverPlugIn;
            OnRequestClose();
        }

        private void DoCmdCancel()
        {
            OnRequestClose();
        }

        #endregion
    }
}
